﻿package 
{
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.ui.*;

    public class UI extends Object
    {

        public function UI()
        {
            return;
        }// end function

        public static function AddToContext(ContextMenuItem:ContextMenu, ContextMenuItem:String, ContextMenuItem:Function, ContextMenuItem:Boolean = false) : void
        {
            var _loc_5:* = new ContextMenuItem(U.RM(ContextMenuItem) + " ", ContextMenuItem, true, true);
            _loc_5.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, ContextMenuItem, false, 1, true);
            ContextMenuItem.customItems.push(_loc_5);
            return;
        }// end function

        public static function GetPart(ContextMenuEvent:BitmapData, ContextMenuEvent:int, ContextMenuEvent:int, ContextMenuEvent:int, ContextMenuEvent:int) : BitmapData
        {
            var _loc_6:* = new BitmapData(ContextMenuEvent, ContextMenuEvent);
            _loc_6.copyPixels(ContextMenuEvent, new Rectangle(ContextMenuEvent, ContextMenuEvent, ContextMenuEvent, ContextMenuEvent), ContextMenuEvent.rect.topLeft);
            return _loc_6;
        }// end function

        public static function Desaturate(ContextMenuEvent:BitmapData) : BitmapData
        {
            var _loc_2:uint = 0;
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_6:int = 0;
            var _loc_7:int = 0;
            while (_loc_7 < ContextMenuEvent.width)
            {
                
                _loc_6 = 0;
                while (_loc_6 < ContextMenuEvent.height)
                {
                    
                    _loc_2 = ContextMenuEvent.getPixel(_loc_7, _loc_6);
                    _loc_3 = _loc_2 >>> 16 & 255;
                    _loc_4 = _loc_2 >>> 8 & 255;
                    _loc_5 = _loc_2 & 255;
                    _loc_5 = 0.299 * _loc_3 + 0.587 * _loc_4 + 0.114 * _loc_5;
                    _loc_4 = _loc_5;
                    _loc_3 = _loc_4;
                    ContextMenuEvent.setPixel(_loc_7, _loc_6, _loc_3 << 16 | _loc_4 << 8 | _loc_5);
                    _loc_6++;
                }
                _loc_7++;
            }
            return ContextMenuEvent;
        }// end function

        public static function CreatePickerIcon(ContextMenuEvent:uint) : BitmapData
        {
            var _loc_2:* = new PickerIcon();
            var _loc_3:* = new BitmapData(20, 20, true, 16777215);
            _loc_3.copyPixels(_loc_2, _loc_2.rect, new Point(0, 0));
            _loc_3.fillRect(new Rectangle(13, 1, 5, 5), ContextMenuEvent);
            return _loc_3;
        }// end function

        public static function Combine(ContextMenuEvent:BitmapData, ContextMenuEvent:BitmapData, ContextMenuEvent:int, ContextMenuEvent:int) : BitmapData
        {
            var _loc_5:Rectangle = null;
            var _loc_6:BitmapData = null;
            if (ContextMenuEvent.rect.containsRect(new Rectangle(ContextMenuEvent, ContextMenuEvent, ContextMenuEvent.width, ContextMenuEvent.height)))
            {
                ContextMenuEvent.copyPixels(ContextMenuEvent, ContextMenuEvent.rect, new Point(ContextMenuEvent, ContextMenuEvent), null, null, true);
                return ContextMenuEvent;
            }
            _loc_5 = ContextMenuEvent.rect.union(new Rectangle(ContextMenuEvent, ContextMenuEvent, ContextMenuEvent.width, ContextMenuEvent.height));
            _loc_6 = new BitmapData(_loc_5.width, _loc_5.height, true, 16777215);
            _loc_6.copyPixels(ContextMenuEvent, ContextMenuEvent.rect, ContextMenuEvent.rect.topLeft, null, null, true);
            _loc_6.copyPixels(ContextMenuEvent, ContextMenuEvent.rect, new Point(ContextMenuEvent, ContextMenuEvent), null, null, true);
            return _loc_6;
        }// end function

    }
}
